---@class Battle.SkillComponent:Battle.BaseComponent
local SkillComponent = Battle.CreateClass("SkillComponent",Battle.BaseComponent)
Battle.SkillComponent = SkillComponent

function SkillComponent:BaseCreate(skill)
    ---@type Battle.Skill
    self.skill = skill        --技能
    self.isExecute = false  --是否已执行
    self.delayTime = 0     --延时执行
    self.curTime = 0        --当前时间
    self.isPause = false
    Battle.BaseComponent.BaseCreate(self)
end
function SkillComponent:BaseDestroy()
    Battle.BaseComponent.BaseDestroy(self)
    self.skill = nil
end

function SkillComponent:SkillStart()
    self.isStart = true
    self.isExecute = false
    if self.delayTime == 0 then
        self:Execute()
        return
    end
    self.curTime = self.delayTime * self.skill.speedRate
end

function SkillComponent:SetDelay(time)
    self.delayTime = time or 0
end
function SkillComponent:Update(dt)
    if not self.isStart then return end
    if self.isExecute then return end
    self.curTime = self.curTime - dt
    if self.curTime > 0 then
        return
    end
    self:Execute()
end
function SkillComponent:Execute()
    if self.isExecute then return end
    self.isExecute = true
    self:OnExecute()
end

function SkillComponent:SkillEnd()
    self.isStart = false
    self:OnSkillEnd()
end
--region override
function SkillComponent:SetData(...)

end
function SkillComponent:OnExecute()

end
--技能结束
function SkillComponent:OnSkillEnd()
end
--endregion override